var e = o(require("../../../@babel/runtime/regenerator")),
  t = require("../../../@babel/runtime/helpers/asyncToGenerator"),
  n = o(require("../../../config/index")),
  r = require("../../../services/base/api"),
  a = require("@/utils/report");
function o(e) {
  return e && e.__esModule ? e : { default: e };
}
var u = require("@/wxParse/wxParse");
Page({
  data: {
    background: "transparent",
    iconTheme: "white",
    CDN: n.default.CDN,
    title: "",
    position: !0,
    currAlbum: 0,
    name: "三星堆博物馆",
    address: "广汉市三星堆博物馆",
    detail: {},
    lat: "31.001404",
    content: "",
    lon: "104.218307",
    wxParse: !0,
    come: "1",
  },
  onShow: function () {
    var n = this;
    return t(
      e.default.mark(function t() {
        var o, s, c;
        return e.default.wrap(function (e) {
          for (;;)
            switch ((e.prev = e.next)) {
              case 0:
                return (
                  (o = n.data.come),
                  (0, a.report)("musuemdetail_show", { source: o }),
                  (e.next = 4),
                  (0, r.postMuseumInfo)()
                );
              case 4:
                (s = e.sent),
                  (c = s.data.content),
                  n.setData({ detail: s.data, content: s.data.content }),
                  u.wxParse("content", "html", c, n, 15);
              case 8:
              case "end":
                return e.stop();
            }
        }, t);
      }),
    )();
  },
  onPageScroll: function (e) {
    e.scrollTop > 60
      ? this.setData({ background: "#FAF3E8", iconTheme: "rgba(0,0,0,0.92)" })
      : this.setData({ background: "transparent", iconTheme: "white" });
  },
  swiperChange: function (e) {
    var t = e.detail.current;
    this.setData({ currAlbum: t }), console.log(e);
  },
  onSwiperImg: function (n) {
    var r = this;
    return t(
      e.default.mark(function t() {
        var a, o;
        return e.default.wrap(function (e) {
          for (;;)
            switch ((e.prev = e.next)) {
              case 0:
                (a = r.data.detail),
                  (o = n.currentTarget.dataset.current),
                  wx.previewImage({ current: o, urls: a.album, showmenu: !1 });
              case 3:
              case "end":
                return e.stop();
            }
        }, t);
      }),
    )();
  },
  onTel: function () {
    var n = this;
    return t(
      e.default.mark(function t() {
        var r, a;
        return e.default.wrap(function (e) {
          for (;;)
            switch ((e.prev = e.next)) {
              case 0:
                (r = n.data.detail),
                  (a = [r.phone] || []),
                  wx.showActionSheet({
                    itemList: a,
                    success: function (e) {
                      wx.makePhoneCall({
                        phoneNumber: a[e.tapIndex],
                        success: function () {
                          console.log("拨打电话成功", a[e.tapIndex]);
                        },
                        fail: function () {
                          console.log("拨打电话失败");
                        },
                      });
                    },
                    fail: function (e) {
                      console.log("拨打电话失败", e);
                    },
                  });
              case 3:
              case "end":
                return e.stop();
            }
        }, t);
      }),
    )();
  },
  onMap: function () {
    var n = this;
    return t(
      e.default.mark(function t() {
        var r, a, o, u, s;
        return e.default.wrap(function (e) {
          for (;;)
            switch ((e.prev = e.next)) {
              case 0:
                (r = n.data),
                  (a = r.name),
                  (o = r.address),
                  (u = r.lat),
                  (s = r.lon),
                  wx.openLocation({
                    latitude: Number(u),
                    longitude: Number(s),
                    name: a,
                    address: o,
                    scale: 18,
                  });
              case 2:
              case "end":
                return e.stop();
            }
        }, t);
      }),
    )();
  },
});
